/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>
#include "dal/domain_participant.h"
#include "dal_fastdds/entity_impl/DalDomainParticipantImpl.hpp"
#include "dal_fastdds/converter/GuidConverter.hpp"
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>

TEST(test_domain_participant_guid, guid_convert_default)
{
    dal_domain_participant_t* participant =
        dal_create_domain_participant(20, DAL_PARTICIPANT_QOS_DEFAULT, nullptr, DAL_ANY_STATUS);
    auto f_participant = reinterpret_cast<DalDomainParticipantImpl*>(participant->handle_)
                             ->FastddsDomainParticipant();
    auto f_guid = f_participant->guid();
    dal_guid_t guid = dal_domain_participant_get_guid(participant);

    auto ret = memcmp(f_guid.guidPrefix.value, guid.guidprefix.value, GUIDPREFIX_SIZE);
    EXPECT_EQ(0, ret);

    ret = memcmp(f_guid.entityId.value, guid.entity_id.value, ENTITYID_SIZE);
    EXPECT_EQ(0, ret);
}
